package BSTTree;

import lombok.Data;

/**
 * Description:
 * Author:    Dane
 * CreateTime:2024/8/24-下午3:12
 * Since  :   1.0
 * Version:   1.0
 */
@Data
public class Node {
    public int value;
    public Node leftNode;
    public Node rightNode;

    public Node(int value) {
        this.value = value;
    }

    public void midOrder() {
        if (this.leftNode != null) {
            this.leftNode.midOrder();
        }
        System.out.println(this.value);
        if (this.rightNode != null) {
            this.rightNode.midOrder();
        }


    }

    public void add(Node node) {
        if (node == null) {
            return;
        }
        if (node.value < this.value) {
            if (this.leftNode == null) {
                this.leftNode = node;
            } else {
                this.leftNode.add(node);
            }
        } else {
            if (this.rightNode == null) {
                this.rightNode = node;
            } else {
                this.rightNode.add(node);
            }
        }


    }


}
